package com.matt.foundation.vo.observation;

import com.matt.domain.observation.Observation;
import com.matt.domain.observation.ObservationOption;
import lombok.Data;

import java.util.List;
import java.util.stream.Collectors;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2017/8/14
 * *******************************
 */
@Data
public class ObservationVo {
    private Long id;

    private String title;

    private List<ObservationOptionVo> options;

    public static ObservationVo of(Observation observation, List<ObservationOption> options){
        ObservationVo vo = new ObservationVo();
        vo.setId(observation.getId());
        vo.setTitle(observation.getTitle());
        List<ObservationOptionVo> voList = options.stream().map(o->ObservationOptionVo.of(o)).collect(Collectors.toList());
        vo.setOptions(voList);
        return vo;
    }
}
